<?php
namespace Home\Model;
use Think\Model;
// +----------------------------------------------------------------------
// | Date:2017年1月16日
// +----------------------------------------------------------------------
// | Author: EK_熊<1439527494@qq.com>
// +----------------------------------------------------------------------
// | Description: 此文件作用于****
// +----------------------------------------------------------------------
class SearchLogModel extends Model{
    
    
    function search_add($keyword,$uid,$type){
        $uid = !$uid ? 0 : $uid;
        return $this->add([
                    'keyword'=>$keyword,
                    'uid'=>$uid,
                    'type'=>$type,
                    'created_time'=>CURRENT_TIME,
                ]);
        
        
    }
    
    
    //热门搜索关键词
    function keyword_hot(){
       $default = ['华为','腾讯','泰国','日用品类','龙玺奖','安全需求'];
       $ret = $this->group('keyword')->order('count(*) desc,created_time desc')->limit(6)->getField('keyword',true);
       if (!$ret) return $default;
       if (count($ret) < 6) return array_merge($ret,$default);
       return $ret;
    }
    
}